﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace xiaolanshu
{
    public partial class 用户登录 : Form
    {
        public static string a;
        public 用户登录()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            注册 f2 = new 注册();
            f2.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = SQLTools.conn;
            // SqlConnection conn = new SqlConnection(@"Server=.\SqlExpress;Database=小兰书;Integrated Security=SSPI;");
            conn.Open();
            string sql1 = @"select 密码 from 用户 where 手机号='" + textBox1.Text + "'";
            SqlCommand cmd = new SqlCommand(sql1, conn);
            if (textBox3.Text == "RRGK" && cmd.ExecuteScalar().ToString() == textBox2.Text)
            {
                label4.Text = "";
                label5.Text = "";
                用户信息.telephone = textBox2.Text;
                分类 f3 = new 分类();
                f3.ShowDialog();
            }
            else
            {
                if (textBox3.Text != "RRGK")
                {
                    textBox2.Text = "";
                    label4.Text = "验证码输入错误！";
                }
                if (cmd.ExecuteScalar().ToString() != textBox2.Text)
                { textBox3.Text = ""; label5.Text = "验证码输入错误"; }
            }
            a = textBox1.Text;
            conn.Close();
                    
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection conn = SQLTools.conn;
            //SqlConnection conn = new SqlConnection(@"Server=.\SqlExpress;Database=小兰书;Integrated Security=SSPI;");
            conn.Open();
            string sql1 = @"select 密码 from 商家 where 手机号='"+textBox1.Text+"'";
            SqlCommand cmd = new SqlCommand(sql1, conn);
            if (textBox3.Text == "RRGK" && cmd.ExecuteScalar().ToString() == textBox2.Text)
            {
                商家信息.ygtelephone = textBox1.Text;
                string sql = @"select 员工姓名 from 商家 where 手机号='" + textBox1.Text + "'";
                SqlCommand cmdd = new SqlCommand(sql, conn);
                商家信息.ygname = cmdd.ExecuteScalar().ToString();
                商家功能 f = new 商家功能();
                f.ShowDialog();
            }
            conn.Close();
            this.Close();
        }

        private void 用户登录_Load(object sender, EventArgs e)
        {

        }
    }
}
